home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: Greatest Hits 1996 / Amiga Games: Greatest Hits 1996.iso / rexx / tstapp.rexx < prev    next >
OS/2 REXX Batch file  |  1994-04-10  |  3KB  |  101 lines

  1. /* 
  2.  
  3. NAME
  4.      TstApp - A convenient way to test an application's ARexx port.
  5.  
  6. SYNOPSIS
  7.      [rx] tstapp <port> [<screen>]
  8.  
  9. DESCRIPTION
  10.      Provides a convenient way to test an application's ARexx port.
  11.      TstApp opens a window through which you can type commands that
  12.      are fed directly to the ARexx port <port>.  The return code
  13.      RC and the RESULTS variable, if applicable, are written to
  14.      the window after the application replies to the message.
  15.  
  16.      <port> must be a valid ARexx port.
  17.  
  18.      <screen> is an optional hex address of the screen to open
  19.      the window on.  Or, a <screen> value of 'front' will cause
  20.      the window to be opened on the front screen.  The <screen>
  21.      parameter requires ConMan to be installed.  It's probably 
  22.      possible to devise code using pure ARexx that will find the
  23.      address of the screen given the name of the screen, but I'd
  24.      prefer not to muck around quite that much, since it's probably 
  25.      dangerous to go walking system lists without Forbid() and
  26.      Permit().  Just juggle screens and use the 'front' option.
  27.      And be careful not to close the screen before quitting TstApp!
  28.  
  29.      TstApp recognizes two commands:  '\res' and '\end'.  Typing
  30.      '\res' toggles the status of OPTIONS RESULTS.  Typing '\end'
  31.      exits TstApp and closes the window.
  32.  
  33. AUTHOR
  34.      TstApp is public domain by Eric Kennedy.  Hope it helps you
  35.      debug your ARexx compatible program, or helps you figure out
  36.      how to use those that you already have.
  37.  
  38. */
  39.  
  40. trace off
  41. options
  42. parse arg appname screen
  43.  
  44. if appname = "" then
  45. do
  46.   say "Usage: rx tstapp <port> [<screen>]"
  47.   say 
  48.   say "<port> must be a valid ARexx port."
  49.   say "<screen> is an optional hex address of the screen to open"
  50.   say "the window on.  Or, a <screen> value of 'front' will cause"
  51.   say "the window to be opened on the front screen.  The <screen>"
  52.   say "parameter requires ConMan to be installed."
  53.   exit
  54. end
  55.  
  56. if screen~="" then
  57. do
  58.   if upper(screen)='FRONT' then screen = 'S*/' 
  59.   else screen='S'||subword(screen,1,1)||'/'    
  60. end
  61.  
  62. if ~Open(MYCON,'CON:'||screen||'100/50/450/125/'||appname||'_test') then
  63. do
  64.   say "Can't open window!"
  65.   exit
  66. end
  67.  
  68. call writeln(MYCON,'Type command for' appname || '. \end to quit')
  69. call writeln(MYCON,'Type \res to toggle OPTIONS RESULTS.')
  70. call writeln(MYCON,'OPTIONS RESULTS is off.')
  71.  
  72. r='n'    /* options results off */
  73.  
  74. address VALUE appname 
  75. do while inp ~= '\end'
  76.   call writech(MYCON,appname||'> ')
  77.   inp = readln(MYCON)
  78.   if inp ~= '\end' then do
  79.     if inp = '\res' then do
  80.       if r = 'y' then do
  81.         options
  82.         r = 'n'
  83.         call writeln(MYCON,'OPTIONS RESULTS is off.')
  84.       end 
  85.       else do
  86.         options results
  87.         r = 'y'
  88.         call writeln(MYCON,'OPTIONS RESULTS is on.')
  89.       end
  90.     end
  91.     else do
  92.       inp
  93.       res=result
  94.       call writeln(MYCON,'RC----->'||RC)
  95.       if r = 'y' then do
  96.         call writeln(MYCON,'result->'||res)
  97.       end
  98.     end
  99.   end
  100. end
  101.